<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>state状态</title>
</head>
<body>
    <div id="test">

    </div>

    <!-- 引入react 核心库 -->
    <script type="text/javascript" src="./js/react.development.js"></script>
    <!-- 引入react-dom 用于支持react操作dom -->
    <script type="text/javascript" src="./js/react-dom.development.js"></script>
    <!-- 引入babel 用于讲jsx转成js -->
    <script type="text/javascript" src="./js/babel.min.js"></script>

    <!-- 组 件 -->
    <script type="text/babel">
       class Weather extends React.Component{
           constructor(props) {
               super(props)
               this.change = this.change.bind(this)
               this.state={
                   isHot:false,
                   msg:'微风'
               }
           }
           change(){
               const hot = this.state.isHot
               this.setState({isHot:!hot})
           }

           render() {
               return <h2 onClick={this.change}>今天天气很{this.state.isHot?'炎热':'凉爽'},{this.state.msg}</h2>
           }
       }
       ReactDOM.render(<Weather/>,document.getElementById('test'))
    </script>
</body>

</html>